/*
 * Copyright (c) 2015 www.smarthome.com All rights reserved. 本软件源代码版权归----所有,未经许可不得任意复制与传播.
 */
package com.smarthome.base.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.smarthome.base.dao.ShUserResourceDao;
import com.smarthome.base.dao.base.BaseDaoImpl;
import com.smarthome.domain.bean.ShUserResource;
import com.smarthome.domain.enums.ShUserResourceOpenFlagEnum;

/**
 * ShUserResourceDao 实现类
 * @author KongXiangyu
 * @since 2015-09-07
 */
@Repository("shUserResourceDao")
public class ShUserResourceDaoImpl extends BaseDaoImpl<ShUserResource, Long> implements ShUserResourceDao {

    private final static String NAMESPACE = "com.smarthome.base.dao.ShUserResourceDao.";

    // 返回本DAO命名空间,并添加statement
    public String getNameSpace(String statement) {
        return NAMESPACE + statement;
    }
    @Override
    public List<ShUserResource> queryUserResourcesByUserAndRole(Long userId, Long residenceId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("userId", userId);
        map.put("residenceId", residenceId);
        return this.selectList(getNameSpace("queryUserResourcesByUserAndRole"), map);
    
    }
    @Override
    public List<ShUserResource> queryUserResourcesByUserId(Long userId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("orderField", "sort_weight");
        map.put("orderFieldType", "ASC");
        map.put("userId", userId);
        map.put("openFlag", ShUserResourceOpenFlagEnum.OPEN.getFlag());
        return this.selectList(getNameSpace("queryUserResourcesByUserId"), map);
    }
}